#include "UnitTest++.h"
#include "Huffman.h"
#include "gList.h"
#include <stdio.h>

TEST(testSizeOcurrence)
{
    GLinkedList<HNode<WordOcurrence> > ocurrences;
    Huffman::countOcurrence("abracadabra", ocurrences);

    CHECK_EQUAL(5, ocurrences.size());
}

TEST(testCountOcurrence)
{
    GLinkedList<HNode<WordOcurrence> > ocurrences;
    Huffman::countOcurrence("abracadabra", ocurrences);
    int amounts [5] = {1, 1, 2, 2, 5};

    for (int i = 0; i < ocurrences.size(); i++)
    {
        CHECK_EQUAL(amounts[i], ocurrences.get(i).getValue().getAmount());
    }
}

TEST(testBuildTree)
{
    GLinkedList<HNode<WordOcurrence> > ocurrences;
    Huffman::countOcurrence("abracadabra", ocurrences);
    Huffman::buildTree(ocurrences);
}